<template>
    <div class="main member-upgrade">
        <section>
            <el-form :model="formData" ref="form">
                <el-form-item label="用户归属：" label-width="100px" :rules="commonRules.notNullSelectRule" prop="type">
                  <el-select v-model="formData.type" placeholder="请选择">
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="用户：" label-width="100px" :rules="commonRules.notNullRule" prop="mobiles">
                    <el-input type="textarea" v-model="formData.mobiles" size="small" placeholder="请输入手机号，多个手机时以逗号分割（英文下逗号）"></el-input>
                </el-form-item>
                <el-form-item label="" label-width="100px">
                    <el-button type="primary" size="small" @click="upgrade" :disabled="btnDisabled">升级官方大区</el-button>
                </el-form-item>
            </el-form>
        </section>
    </div>
</template>
<script>
    export default {
        name: 'upgradeOfficalRegion',
        data(){
            return {
              options: [
                {value: '1', label: '普通及大区'},
                {value: '2', label: '城市合伙人大区'}
              ],
                formData: {
                  mobiles: ''
                },
                btnDisabled: false
            }
        },
        methods: {
            upgrade(){
                this.$refs.form.validate(valid => {
                    if (!valid) {
                        return false;
                    }
                    let list = this.formData.mobiles
                    let result = list.split(',')
                    this.formData.mobileList = result
                    this.btnDisabled = true
                    this.request({
                        url: '/bsnl-product/box/label/updateOfficeRegion',
                        method: 'post',
                        data: this.formData
                    }).then(res => {
                        this.btnDisabled = false;
                        this.$message({
                          type: 'success',
                          dangerouslyUseHTMLString: true,
                          message: res.message
                        });
                    }).catch(err => {
                        this.btnDisabled = false;
                    });
                });
            }
        }
    }
</script>
